#ifndef TAXONOMY_TREE_H
#define TAXONOMY_TREE_H
#include "ti.h"
#include "tplate.h"

typedef struct {
    float *stat;
} one_node;                        // probability mass function for each node in the tree

typedef struct {
    one_node *node;
    int NR_cate;                // number of categories
} taxonomy_tree;

typedef struct {
    taxonomy_tree **t_tree;
    int max_scale;
} ALL_taxonomy_tree;            // Here we use a tree to store the probability of co-occurrence of categories instead of an array. This can save disk spaces and has little impact on the speed of the algorithm.

taxonomy_tree *init_taxonomy_tree(int tpsize, int NR_cate);
void update_taxonomy_tree(taxonomy_tree * t_tree,
                          int *cur_value, int *neigh_value,
                          int tp_position);
taxonomy_tree *build_taxonomy_tree(train_grid * ti, tplate * tp, int g);
void search_taxomony_tree(float *result, taxonomy_tree * t_tree,
                          int tp_position, int *cond, float *marginal);
void save_taxonomy_tree(ALL_taxonomy_tree * alltree, int tpsize,
                        char *filename);
void load_taxonomy_tree(ALL_taxonomy_tree * alltree, int tpsize,
                        char *filename);
float *extract_all_pdf(data_event * dv, taxonomy_tree * t_tree,
                       float *marginal, int NR_cate);
#endif                            /* ifndef TAXONOMY_TREE_H */
